<!-- 公共脚部 -->
<div class="M-foot">
    <div>

        <a href="">新浪微博</a>

        <div id="M-weixin">微信公众号</div>

    </div>
    <div>
        <p>官网商城 2007-2017，版权所有 京ICP备888888888号-1</p>
    </div>
</div>
<!-- 微信公众号弹出层 -->
<div class="M-weixin">
    <div class="M-weixin-content">
        <div>
            <span class="iconfont icon-cuowutishi" id="M-weixin-esc"></span>
        </div>
        <div>
            <img src="{$wx_qrcode_img}" alt="">
            <p>请用微信扫一扫</p>
        </div>
    </div>
</div>
<!-- 移动端选择城市 -->
<!--<div class="M-location" {if condition="$is_cookie_city eq 1"} style="display:none;" {/if}>-->
<!--<div class="M-location-content">-->
<!--<div>-->
<!--选择城市-->
<!--<span>定位：{$cur_city}</span>-->
<!--</div>-->
<!--<div>-->
<!--<ul>-->
<!--{foreach name="city_list" item="v"}-->
<!--<li class="M-location-li {if condition='$cur_city eq $v.value'} M-location-zhong {/if}">{$v.value}</li>-->
<!--{/foreach}-->
<!--</ul>-->
<!--</div>-->
<!--<div>-->
<!--<div>确定</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->

<div class="M-location" {if condition="$is_cookie_city eq 1" } style="display:none;" {/if}>
    <div class="M-location-content mchengshi">
        <div>
            选择城市
            <span>定位：{$cur_city}</span>
        </div>
        <div>
            <ul>
                {foreach name="city_list" item="v"}
                <li class="M-location-li {if condition='$cur_city eq $v.value'} M-location-zhong {/if}" data-city-key="{$v.key}">{$v.value}</li>
                {/foreach}
            </ul>
        </div>
        <div>
            <div onclick="mchengshi()">确定</div>
        </div>
    </div>
    <div class="M-location-content mdianpu" style="display: none;">
        <div>
            选择店铺
            <span></span>
            <span class="iconfont icon-xiangzuo " onclick="mfanhui()"></span>
        </div>
        <div>
            <ul class="get_store">
                <!--<li class="M-location-li M-location-zhong ">五四广场一店</li>-->
                <!--<li class="M-location-li">五四广场一店</li>-->
                <!--<li class="M-location-li">五四广场一店</li>-->
                <!--<li class="M-location-li">五四广场一店</li>-->
                <!--<li class="M-location-li">五四广场一店</li>-->
                <!--<li class="M-location-li">五四广场一店</li>-->
                <!--<li class="M-location-li">五四广场一店</li>-->
                <!--<li class="M-location-li">五四广场一店</li>-->
                <!--<li class="M-location-li">五四广场一店</li>-->
            </ul>
        </div>
        <div>
            <div onclick="choose_m_store();">确定</div>
        </div>
    </div>
</div>
<script>
    function mchengshi() {
        $('.mchengshi').css('display', 'none');
        $('.mdianpu').css('display', 'block');
        var city_key = $('.M-location-zhong').attr('data-city-key');
        $.post("{:url('Changestore/get_store')}", {
                city_key: city_key
            },
            function (data) {
                if (data.code == 1) {
                    var html = '';
                    html += '<li class="M-location-li M-location-zhong" data-store-id="' + data.data[0]["id"] +
                        '" onclick="gaibian_class(this)">' + data.data[0]["title"] + '</li>';
                    for (var i = 1; i < data.data.length; i++) {
                        html += '<li class="M-location-li" data-store-id="' + data.data[i]["id"] +
                            '" onclick="gaibian_class(this)">' + data.data[i]["title"] + '</li>';
                    }
                    $('.get_store').html(html);
                } else {
                    layer.msg(data.msg, {
                        icon: 2,
                        time: 1000
                    }, function (index) {
                        layer.close(index);
                    });
                    return false;
                }
            }
        );
    }

    function mfanhui() {
        $('.mchengshi').css('display', 'block');
        $('.mdianpu').css('display', 'none');
    }

    function choose_m_store() {
        var store_id = $('.get_store li.M-location-zhong').attr('data-store-id');
        if (store_id == '') {
            layer.msg('请选择门店', {
                icon: 2,
                time: 1000
            }, function (index) {
                layer.close(index);
            });
            return false;
        }

        $.post("{:url('Changestore/choose_store')}", {
                store_id: store_id
            },
            function (data) {
                if (data.code == 1) {
                    location.reload();
                } else {
                    layer.msg('网络请求错误，请稍后再试', {
                        icon: 2,
                        time: 1000
                    }, function (index) {
                        layer.close(index);
                    });
                    return false;
                }
            }

        );
    }
    /**
     * 改变样式
     */
    function gaibian_class(obj) {
        $('.M-location-li').removeClass(' M-location-zhong');
        $(obj).addClass(' M-location-zhong');
    }
</script>